﻿namespace Arms.Domain
{
    using System;

    public class EntityFactory
    {
        /// <summary>
        /// Creates a new entity with an ID and state set to active.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static T CreateEntity<T>() where T : Entity, new()
        {
            T entity = new T();
            //entity.GenerateIdentity();
            entity.ActiveState = EntityActiveState.Active;
            return entity;
        }
        /// <summary>
        /// Creates a new entity with an ID, state set to active and with a name.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="name"></param>
        /// <returns></returns>
        public static T CreateEntityDescribed<T>(string name) where T : EntityDescribed, new()
        {
            return EntityFactory.CreateEntityDescribed<T>(name, string.Empty, string.Empty);
        }
        /// <summary>
        /// Creates a new entity with an ID, state set to active and with a name and description.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="name"></param>
        /// <param name="description"></param>
        /// <returns></returns>
        public static T CreateEntityDescribed<T>(string name, string description) where T : EntityDescribed, new()
        {
            return EntityFactory.CreateEntityDescribed<T>(name, description, string.Empty);
        }
        /// <summary>
        /// Creates a new entity with an ID, state set to active and with a name, description and comments
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="name"></param>
        /// <param name="description"></param>
        /// <param name="comments"></param>
        /// <returns></returns>
        public static T CreateEntityDescribed<T>(string name, string description, string comments) where T : EntityDescribed, new()
        {
            T entity = EntityFactory.CreateEntity<T>();
            entity.Name = name;
            entity.Description = description;
            entity.Comment = comments;
            return entity;
        }
    }
}
